package com.quktzhuanka.app.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.quktzhuanka.app.R;
import com.quktzhuanka.app.bean.TeamListBean;
import com.zhy.adapter.abslistview.CommonAdapter;
import com.zhy.adapter.abslistview.ViewHolder;

import java.util.List;

public class MyMarketAdapter extends CommonAdapter<TeamListBean.Teamlist> {

    public MyMarketAdapter(Context context, int layoutId, List<TeamListBean.Teamlist> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convert(ViewHolder viewHolder, TeamListBean.Teamlist item, int position) {
        ImageView imageView = viewHolder.getView(R.id.image_icon);
        Glide.with(mContext).load(item.getAvatar()==null?"":item.getAvatar()).dontAnimate().error(R.mipmap.icon_defult_boy).skipMemoryCache(true).into(imageView);
        viewHolder.setText( R.id.title_tv,item.getName()+"  ");
        //动态设置drawableLeft属性
        if("Y".equals(item.getIs_buy())){
            Drawable drawable1 =mContext.getResources().getDrawable(R.mipmap.gouwu);
            drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight());
            ((TextView)viewHolder.getView(R.id.title_tv)).setCompoundDrawables(null, null, drawable1, null);
        }else{
            ((TextView)viewHolder.getView(R.id.title_tv)).setCompoundDrawables(null, null, null, null);
        }
        viewHolder.setText(R.id.jishu_tv,item.getGroup_name());
        viewHolder.setText(R.id.yaoqingren_tv,"他的邀请："+item.getReferrer_num());
        if(item.getRegister_time()==null||item.getRegister_time().equals("")){
            viewHolder.setText(R.id.yaoqingren_ont_tv,"邀请人："+item.getReferrer_name());
        }else{
            viewHolder.setText(R.id.yaoqingren_ont_tv,"时间："+item.getRegister_time().split(" ")[0]);
        }
    }
}
